<?php
$width=Yii::app()->params['dialog']['findTruckForVerification']['width'];
$height=Yii::app()->params['dialog']['findTruckForVerification']['height'];
$cs=Yii::app()->clientScript;
$cs->registerScriptFile('./js/modal.js');
$cs->registerScript('truck_verification_dialog',<<<END
function Block(){
var title; var kind=$("#Vehicle_insurance_kind").val();
if(kind==0) title="请选择车辆"; else title="请选择尾板";
 \$.modal('?r=dialog/findTruckForVehicle&kind='+kind,{width:$width,height:$height,title:title});return false;}
$("#findTruck").click(Block);
$("#Vehicle_insurance_kind").change(function(){\$("#Vehicle_insurance_type").val('');$("#Vehicle_insurance_plate_no").val('');$("#Vehicle_insurance_fk_truck_id").val('');$("#Vehicle_insurance_property_owner").val('');});
function calculate(){if($(this).valid()){var total=Number($("#Vehicle_insurance_another_cost").val())+Number($("#Vehicle_insurance_insurance_cost").val());$("#Vehicle_insurance_total_cost").val(Math.round(total*100)/100);}}
$("#calculate").click(calculate);
$("form").submit(calculate);
END
)
?>
<div class="yiiForm">
<?php
	echo EHtml::form();	
	EHtml::setOptions(array('errorElement'=> 'span'));
	EHtml::setScenario($update ? 'update' : 'create');				  		
?>
<div>注：<span class="required">*</span>为必填项</div>
<div id="leftaa">
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'kind'); ?>
<?php echo EHtml::activeDropDownList($model,'kind',$model->getKindNames()); ?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'plate_no'); ?>
<?php echo EHtml::activeTextField($model,'plate_no',array('size'=>7,'class'=>'readonly','readOnly'=>'true')); ?>
<?php echo CHtml::activeHiddenField($model,'fk_truck_id');?>&nbsp;&nbsp;<a id="findTruck" href="#">查找车辆/尾板</a>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'type'); ?>
<?php echo EHtml::activeTextField($model,'type',array('class'=>'readonly','readOnly'=>'true','size'=>15)); ?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'property_owner'); ?>
<?php echo EHtml::activeTextField($model,'property_owner',array('class'=>'readonly','readOnly'=>'true')); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'premium_name'); ?>
<?php echo EHtml::activeTextField($model,'premium_name',array('size'=>20,'maxlength'=>30)); ?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'insurer'); ?>
<?php echo EHtml::activeTextField($model,'insurer',array('size'=>20,'maxlength'=>100)); ?>
</div>
<div class="simple"  style="border-bottom:0px;">

</div>
</div>
  <div id="rightaa">

<div class="simple">
<?php echo CHtml::activeLabelEx($model,'policyno'); ?>
<?php echo EHtml::activeTextField($model,'policyno',array('size'=>20,'maxlength'=>50)); ?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'effectdate'); ?>
<?php echo EHtml::activeTextField($model,'effectdate',array('id'=>'effectdate','size'=>10)); ?>
<?php $this->widget('application.extensions.calendar.SCalendar',array('inputField'=>'effectdate','ifFormat'=>'%Y-%m-%d',));?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'lapsedate'); ?>
<?php echo EHtml::activeTextField($model,'lapsedate',array('id'=>'lapsedate','size'=>10)); ?>
<?php $this->widget('application.extensions.calendar.SCalendar',array('inputField'=>'lapsedate','ifFormat'=>'%Y-%m-%d',));?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'premium'); ?>
<?php echo EHtml::activeTextField($model,'premium',array('size'=>8)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'insurance_cost'); ?>
<?php echo EHtml::activeTextField($model,'insurance_cost',array('size'=>8)); ?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'another_cost'); ?>
<?php echo EHtml::activeTextField($model,'another_cost',array('size'=>8,'maxlength'=>30)); ?>
</div>
<div class="simple" style="border-bottom:0px;">
<?php echo CHtml::activeLabelEx($model,'total_cost'); ?>
<?php echo EHtml::activeTextField($model,'total_cost',array('size'=>8)); ?><input id="calculate" type="button" value="计算总费用"/>
</div>
</div>
<div class="action">
<?php echo EHtml::submitButton($update ? '更新信息' : '添加信息'); ?>
</div>

<?php echo EHtml::endForm(); ?>

</div><!-- yiiForm -->
<?php 
if($model->hasErrors()) echo "<script>alert('您填写的信息有误！请根据页面红色图标提示修改。');</script>";
?>